gpsbabel.git
6 years agoMerge pull request #518 from gpsbabel/kmlfencepost
GPSBabel [Thu, 19 Mar 2020 01:34:54 +0000 (20:34 -0500)]
Merge pull request #518 from gpsbabel/kmlfencepost

Let KML <TimeSpan> interpolation not count the ending fencepost

6 years agomodernize radius filter ... (#511)
tsteven4 [Wed, 18 Mar 2020 18:50:04 +0000 (12:50 -0600)]
modernize radius filter ... (#511)

* modernize radius filter ...

and fix a memory leak when maxcount option discards wpts.

* radius loop safety.

* allow any Comparable with Waypoint/Route List sort.

* use static_cast instead of reinterpret_cast to

recover original type from void*.

6 years agoCLI renamed to gpsbabel on all builds. (#520)
tsteven4 [Wed, 18 Mar 2020 13:13:05 +0000 (07:13 -0600)]
CLI renamed to gpsbabel on all builds. (#520)

This chases some lose ends from
23379e741bf98603a5737e6f36422b753fc4bbdb

6 years agoSuspend uploading to transfer.sh. Sites refer to it as "now broken" and
Robert Lipe [Mon, 16 Mar 2020 10:06:27 +0000 (05:06 -0500)]
Suspend uploading to transfer.sh. Sites refer to it as "now broken" and
"pending sale". My own testing shows that it saturates all the sockets for
a connection and dies with zero bytes transferred. Build server is about the
same.

This is a mechanical side-port of 33085422627563885c59e60d47d1c9085f48e9a4
which went to the trunk instead of the branch, wheree it'sn needed. Same code

6 years agoSuspend uploading to transfer.sh. Sites refer to it as "now broken" and
Robert Lipe [Mon, 16 Mar 2020 09:47:25 +0000 (04:47 -0500)]
Suspend uploading to transfer.sh. Sites refer to it as "now broken" and
"pending sale". My own testing shows that it saturates all the sockets for
a connection and dies with zero bytes transferred. Build server is about the
same

6 years agoFix generated IGC file to refelect recent change in our KML reader.
Robert Lipe [Fri, 13 Mar 2020 08:18:07 +0000 (03:18 -0500)]
Fix generated IGC file to refelect recent change in our KML reader.

6 years agoMerge pull request #514 from tsteven4/simplifyopt3
GPSBabel [Fri, 13 Mar 2020 05:48:44 +0000 (00:48 -0500)]
Merge pull request #514 from tsteven4/simplifyopt3

    optimize simplify filter.

6 years agoDont count ending fencepost when interpolating TimeSpan in KML reader.
Robert Lipe [Fri, 13 Mar 2020 05:35:53 +0000 (00:35 -0500)]
Dont count ending fencepost when interpolating TimeSpan in KML reader.

6 years agoMake command line version lower case only - everywhere.
Robert Lipe [Fri, 13 Mar 2020 05:21:39 +0000 (00:21 -0500)]
Make command line version lower case only - everywhere.

6 years ago optimize simplify filter.
tsteven4 [Wed, 26 Feb 2020 01:53:32 +0000 (18:53 -0700)]
optimize simplify filter.

    drop unused member ordinal from xte struct.  This, and changes in
    the implementation of shuffle_xte,
    result in a ~13% speed improvement for long routes.

    use new/delete instead of *alloc/free.

    provide initializers for all data members.

    use strtol instead of atol.

    update casting to c++.

6 years agomake shape a subclass of Format. (#512)
tsteven4 [Mon, 24 Feb 2020 18:22:16 +0000 (11:22 -0700)]
make shape a subclass of Format. (#512)

* make shape a subclass of Format.

* correct type of 2nd param passed to SHPCreateSimpleObject

6 years agouse initializer list to construct gpx tag hash. (#509)
tsteven4 [Thu, 20 Feb 2020 14:53:15 +0000 (07:53 -0700)]
use initializer list to construct gpx tag hash. (#509)

6 years agoupdate format specific handling. (#502)
tsteven4 [Thu, 20 Feb 2020 14:48:28 +0000 (07:48 -0700)]
update format specific handling. (#502)

* update format specific handling.

Format specific allocate, copy, destroy functions use new/delete for
underlying data management.  Use brace intitializers for underlying
data.  Previous xmalloc/xcalloc and xfree were used.

Format specific copy functions use copy constructor of underlying data.

Format specific copy functions have a const source.

Format specific functions use static_cast instead of c-style casts.
This helps avoid casting away const accidentally.

When possible, assign the result of fs_chain_find to a const pointer.

Eliminate corruption of global lists by AN1 writer which was modifying
format specific data.  This also simplifies memomry management and
fixes a double delete.

Fix const correctness issues with an1 symbol lookup.

Correct an1 symbol lookup to avoid dependency on structure padding.

Catch make-an1sym.pl with an1sym.h.

* use reinterpret_cast w/ fs_chain_add fs_chain_find ...

instead of c-style casts.

* make format_specifc_data a base class

and the various flavors derived classes.

* use a QList for format_specific_data chains.

* split format specific defines ...

use reinterpret_cast to downcast format_specific_data.  dynamic_cast
is noticeably slower.

* add new formspec.h file.

* create FormatSpecificDataList class.

rename format specific related items.

* safety check for formspec nullptr function ptrs.

* replace format specific function pointers

with pure virtual clone function and dtor.

6 years agoextend travis cache expiration date. (#510)
tsteven4 [Wed, 19 Feb 2020 20:35:59 +0000 (13:35 -0700)]
extend travis cache expiration date. (#510)

6 years agoMore thoroughly hide clearly broken code that should exist only on a branch
Robert Lipe [Sun, 16 Feb 2020 06:30:23 +0000 (00:30 -0600)]
More thoroughly hide clearly broken code that should exist only on a branch
that seeped into master when I added an epmpty file.

6 years agoRemove debugging.
Robert Lipe [Sun, 16 Feb 2020 05:04:59 +0000 (23:04 -0600)]
Remove debugging.

6 years agoDelete debuging from yahoo.
Robert Lipe [Sun, 16 Feb 2020 05:03:24 +0000 (23:03 -0600)]
Delete debuging from yahoo.

6 years agoSomething empty to force a codacy push.
Robert Lipe [Sun, 16 Feb 2020 04:55:38 +0000 (22:55 -0600)]
Something empty to force a codacy push.

6 years agoMerge branch 'master' of https://github.com/gpsbabel/gpsbabel
Robert Lipe [Sun, 16 Feb 2020 04:55:00 +0000 (22:55 -0600)]
Merge branch 'master' of https://github.com/gpsbabel/gpsbabel

6 years agoretire route_head_alloc(). (#507)
tsteven4 [Sat, 15 Feb 2020 22:37:45 +0000 (15:37 -0700)]
retire route_head_alloc(). (#507)

6 years agoreference file relocation. (#506)
tsteven4 [Sat, 15 Feb 2020 19:26:44 +0000 (12:26 -0700)]
reference file relocation. (#506)

move geocaching.loc into reference directory.
use ${REFERENCE} to find reference files.  not reference.  not nothing.

6 years agoImplement GCID parsing in unicsv and extend ID to 64bit (#501)
Ralf Horstmann [Fri, 14 Feb 2020 20:09:38 +0000 (21:09 +0100)]
Implement GCID parsing in unicsv and extend ID to 64bit (#501)

* Implement GCID parsing in unicsv and extend ID to 64bit

This reimplements the parser and adds some test cases. The test
cases have been validated with several online converters, so this
hopefully works better than the previous implementation.

This also fixes an endless loop that afl managed to trigger.

* Fix clazy warning in unicsv

* Add GC-ID test cases, documentation, int parsing

- Explicitly do the integer parsing with base 10, otherwise hex
  values and octal values would be accepted with 0x and 0 prefix.
- Add testcases that cover GC-ID parsing, including some invalid cases
- Unify the terminology (GC-Code vs GC-ID)
- Add examples to the unicsv documentation showing that both GC-ID
  and GC-Code are accepted

6 years agowarning fixes (#505)
tsteven4 [Thu, 13 Feb 2020 14:51:34 +0000 (07:51 -0700)]
warning fixes (#505)

* fix some qt deprecations and a warning.

* fix fixes.

* fix comment

6 years agouse standard bionic image for travis coverage build. (#504)
tsteven4 [Wed, 12 Feb 2020 18:01:53 +0000 (11:01 -0700)]
use standard bionic image for travis coverage build. (#504)

6 years agoSome more fixes for issues found by afl/asan (#500)
Ralf Horstmann [Wed, 12 Feb 2020 16:19:01 +0000 (17:19 +0100)]
Some more fixes for issues found by afl/asan (#500)

* Fix uninitialized warning in lowranceusr

* Fix stack buffer overlow in lowranceusr

%15.10f may produce more characters than what fits into the
buffer of 32 bytes. Use std::isnan to avoid the sprintf.

==2133227==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff9bab5b20 at pc 0x7fc83fd95865 bp 0x7fff9bab57e0 sp 0x7fff9bab4f70
WRITE of size 38 at 0x7fff9bab5b20 thread T0
    #0 0x7fc83fd95864 in vsprintf (/lib64/libasan.so.5+0x9e864)
    #1 0x7fc83fd95d1e in sprintf (/lib64/libasan.so.5+0x9ed1e)
    #2 0x767bbb in lowranceusr_parse_waypt /home/gpsbabel/gpsbabel.git/lowranceusr.cc:813
    #3 0x77be54 in lowranceusr_parse_waypts /home/gpsbabel/gpsbabel.git/lowranceusr.cc:1116
    #4 0x781151 in data_read /home/gpsbabel/gpsbabel.git/lowranceusr.cc:1658
    #5 0xc7ac71 in run /home/gpsbabel/gpsbabel.git/main.cc:339
    #6 0x4cdd62 in main /home/gpsbabel/gpsbabel.git/main.cc:707
    #7 0x7fc83f29d1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #8 0x4cef7d in _start (/home/gpsbabel/gpsbabel.git/gpsbabel+0x4cef7d)

* Ensure string is terminated mps_readstr in mapsource

When EOF or buffer limit is reached, the return buffer might not be
zero-terminated. So add termination at the end of the buffer and read
max sz - 1 bytes from file instead of sz bytes.

==2145172==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffd2ba34e00 at pc 0x7f005812dbbd bp 0x7ffd2ba34860 sp 0x7ffd2ba34008
READ of size 1028 at 0x7ffd2ba34e00 thread T0
    #0 0x7f005812dbbc  (/lib64/libasan.so.5+0x67bbc)
    #1 0x557c62 in QString::fromUtf8(char const*, int) /usr/include/qt5/QtCore/qstring.h:572
    #2 0x557c62 in QString::operator=(char const*) /usr/include/qt5/QtCore/qstring.h:706
    #3 0x557c62 in mps_waypoint_r /home/gpsbabel/gpsbabel.git/mapsource.cc:571
    #4 0x55edd4 in mps_read /home/gpsbabel/gpsbabel.git/mapsource.cc:1675
    #5 0xc7adb1 in run /home/gpsbabel/gpsbabel.git/main.cc:339
    #6 0x4ce082 in main /home/gpsbabel/gpsbabel.git/main.cc:707
    #7 0x7f005766c1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #8 0x4cf29d in _start (/home/gpsbabel/gpsbabel.git/gpsbabel+0x4cf29d)

Address 0x7ffd2ba34e00 is located in stack of thread T0 at offset 1344 in frame
    #0 0x556e8f in mps_waypoint_r /home/gpsbabel/gpsbabel.git/mapsource.cc:507

  This frame has 6 object(s):
    [48, 56) 'wptdesc' (line 538)
    [80, 88) '<unknown>'
    [112, 120) '<unknown>'
    [144, 152) '<unknown>'
    [176, 276) 'tbuf' (line 508)
    [320, 1344) 'wptname' (line 509) <== Memory access at offset 1344 overflows this variable

* Fix off-by-one list access in pcx reader

* Prevent stack based buffer overflow in gdb reader

* Prevent global buffer overflow in garmin_fit

The message_def array is 16 bytes long, make sure local_id stays
within range, same as in other places in garmin_fit.

Found by afl which managed to create a call to fit_parse_data_message
with a header value of 0x1f:

==2927747==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000010a3bd8 at pc 0x000000a91bba bp 0x7ffd82584a90 sp 0x7ffd82584a80
READ of size 4 at 0x0000010a3bd8 thread T0
    #0 0xa91bb9 in fit_parse_data /home/gpsbabel/gpsbabel.git/garmin_fit.cc:549
    #1 0xa92ae3 in fit_parse_data_message /home/gpsbabel/gpsbabel.git/garmin_fit.cc:821
    #2 0xa92ae3 in fit_parse_record /home/gpsbabel/gpsbabel.git/garmin_fit.cc:864
    #3 0xa92ae3 in fit_read /home/gpsbabel/gpsbabel.git/garmin_fit.cc:884
    #4 0xc7cdb1 in run /home/gpsbabel/gpsbabel.git/main.cc:339
    #5 0x4ce142 in main /home/gpsbabel/gpsbabel.git/main.cc:707
    #6 0x7f4f3b2651a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #7 0x4cf35d in _start (/home/gpsbabel/gpsbabel.git/gpsbabel+0x4cf35d)

6 years agoRework interpolate filter, retire some magic numbers. (#498)
tsteven4 [Sun, 9 Feb 2020 19:36:54 +0000 (12:36 -0700)]
Rework interpolate filter, retire some magic numbers. (#498)

* rewrite interpolate filter.

What started out as an investigation of a clang-tidy warning about
a floating point loop counter (FloatLoopCounter, cert-flp30-c)
turned into this.

Use integer loop counters.
Use a variable step size, that is constant for each span, to meet the
constraint of no interval > limit.
Previously steps of the limit size were used leaving the last step in
a span of a different likely shorter size.
Be defensive about user input and track/route input, no more infinite
loops for negative time limits.
Support milliseconds.
Reduce duplication.
Enhance test to more easily verify interpolation steps.
More efficient route list maniupulation.
Correct documentation.
Correct signed literals use with the unsigned argtype.

This does reiterate, but not fix, the deficiency in route_head copying
that recently came up where new members of route_head are not copied.

* correct test to use long long format for TIMET_TIME_MS.

* Eliminate some magic numbers for unit conversion.

Previously the conversion factor for meters to feet was inaccurate.  Correcting
this caused a couple kml test cases to change.

The ozi test was problematic, an altitiude was provided that endend in
0.5 feet, and was printed out rounded to feet.  A one bit error in the
mantissa of the double involved in the round trip to meters could change
the rounding result.  To fix this the ozi writer was changed to print
track altitudes to a tenth of a foot.  This matches an ozi track file found in
the wild as well as our own ozi track sample.

The classic-2 test involving gnuplot.style printed altitude to one millonth
of a foot, i.e. 0.3 micrometers!  The gnu plot style was changed to print
to the thousandth of a foot, i.e. 0.3 millimeters.

6 years agoSome fixes for issues found with afl and address sanitizer (#499)
Ralf Horstmann [Sun, 9 Feb 2020 17:02:34 +0000 (18:02 +0100)]
Some fixes for issues found with afl and address sanitizer (#499)

* Fix off-by-one in nmea reader

Found with afl and address sanitizer:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==2615627==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f54eaa53683 bp 0x7ffd187eed00 sp 0x7ffd187ee4b8 T0)
==2615627==The signal is caused by a READ memory access.
==2615627==Hint: address points to the zero page.
    #0 0x7f54eaa53682 in QString::chop(int) (/lib64/libQt5Core.so.5+0x13c682)
    #1 0x5e8d7f in gpgsa_parse /home/gpsbabel/gpsbabel.git/nmea.cc:744
    #2 0x5e8d7f in nmea_parse_one_line /home/gpsbabel/gpsbabel.git/nmea.cc:1021
    #3 0x5f0b6f in nmea_read /home/gpsbabel/gpsbabel.git/nmea.cc:1096
    #4 0xc7e483 in run /home/gpsbabel/gpsbabel.git/main.cc:339
    #5 0x4ced15 in main /home/gpsbabel/gpsbabel.git/main.cc:707
    #6 0x7f54ea3f71a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #7 0x4cffdd in _start (/home/gpsbabel/gpsbabel.git/gpsbabel+0x4cffdd)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib64/libQt5Core.so.5+0x13c682) in QString::chop(int)
==2615627==ABORTING

* Fix heap buffer overflow in igc reader

In gbfgetstr(), when file->buff contains exactly file->buffsz
characters including null termination, there is no room to
append another character with strcat() in igc.cc

Found by afl with address sanitizer:

==2082077==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x611000001f40 at pc 0x7f5a4e0da6cd bp 0x7ffd14ffe040 sp 0x7ffd14ffd7e8
WRITE of size 2 at 0x611000001f40 thread T0
    #0 0x7f5a4e0da6cc  (/lib64/libasan.so.5+0x9b6cc)
    #1 0x7327cf in data_read /home/gpsbabel/gpsbabel.git/igc.cc:334
    #2 0xc7a3c1 in run /home/gpsbabel/gpsbabel.git/main.cc:339
    #3 0x4cddf2 in main /home/gpsbabel/gpsbabel.git/main.cc:707
    #4 0x7f5a4d5e51a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #5 0x4cf00d in _start (/home/gpsbabel/gpsbabel.git/gpsbabel+0x4cf00d)

0x611000001f40 is located 0 bytes to the right of 256-byte region [0x611000001e40,0x611000001f40)

* Fix endless loop in mapsource

The loop around gbfread needs a check for eof, otherwise it
may never terminate with special input created by afl.

6 years agoadd address sanitizer, undefined behavior sanitizer, clazy to CI (#497)
tsteven4 [Thu, 6 Feb 2020 23:46:06 +0000 (16:46 -0700)]
add address sanitizer, undefined behavior sanitizer, clazy to CI (#497)

* enhance travis tools

These are run under ubuntu eoan to get tools close to the
bleeding edge.
add address sanitizer
add undefined behavior sanitizer
add clazy

* fix clazy warning ...

now that we know travis catches it.

6 years agomiscellaneous cleanups (#496)
tsteven4 [Thu, 6 Feb 2020 01:45:52 +0000 (18:45 -0700)]
miscellaneous cleanups (#496)

* msvc, resharper fixes

Some "Qualifier is redundant"
"Redundant empty declaration"
"Redundant empty statement"

* restore missing comment

* various corrections ...

clazy clang-range-loop
some casting that confuse clang-tidy google-readability-casting

6 years agouse rounding when interpolating time in arcdist filter. (#495)
tsteven4 [Wed, 5 Feb 2020 19:47:03 +0000 (12:47 -0700)]
use rounding when interpolating time in arcdist filter. (#495)

eliminate uneccessary casting away of const.
reduce variable scope.

6 years agoreimplement nmea waypoint status tracking. (#494)
tsteven4 [Wed, 5 Feb 2020 18:52:31 +0000 (11:52 -0700)]
reimplement nmea waypoint status tracking. (#494)

62ae2fadb replaced waypoint status tracking based on Queues with
a derived class of Waypoint.  This has proven problematic, see
https://github.com/gpsbabel/gpsbabel/pull/491

This PR implements the waypoint status stracking using the extra_data
member of Waypoint instead of using a dervied class.

6 years agofix stack buffer overflow errors in igc reader.
tsteven4 [Wed, 5 Feb 2020 18:44:54 +0000 (18:44 +0000)]
fix stack buffer overflow errors in igc reader.

These were discoverd by gcc 9.2.1 address sanitizer.
They were introduced in 24195b5c4.  The [ conversion specifier
always stores a null character in addition to the characters matched
(so the argument array must have room for at least width+1 characters)

6 years agore-implement gpx version handling. (#488)
tsteven4 [Tue, 4 Feb 2020 23:20:19 +0000 (16:20 -0700)]
re-implement gpx version handling. (#488)

Clean up data members related to version information.
Avoid casting string literals to (non-const) char*s.

6 years agofix removal of tomtom test temporary ov2 file (#492)
Chris Mayo [Tue, 4 Feb 2020 20:31:39 +0000 (20:31 +0000)]
fix removal of tomtom test temporary ov2 file (#492)

6 years agorelocate no output format display routine. (#486)
tsteven4 [Tue, 4 Feb 2020 16:31:45 +0000 (09:31 -0700)]
relocate no output format display routine. (#486)

* relocate no output format display routine.

waypt_disp() is used by main when no output format is specified.
This moves that routine from waypt.cc to main.cc.

* clean up exit from main.

don't leave the global_waypoint_list lying around.

return from main instead of calling exit.

6 years agoxcsv TIMET_TIME, TIMET_TIME_MS fix for the last fix. (#490)
tsteven4 [Tue, 4 Feb 2020 13:07:36 +0000 (06:07 -0700)]
xcsv TIMET_TIME, TIMET_TIME_MS fix for the last fix. (#490)

* xcsv TIMET_TIME, TIMET_TIME_MS fix for the last fix.

e483407cf recently made a "fix" to TIMET_TIME_MS output.  Unfortunately
it used a non-standard strftime specifier.  While this worked on
linux systems it crashed with MSVC.

This removes strftime processing from TIMET_TIME_MS output.  This makes
TIME_TIME, TIMET_TIME_MS analogous.  Also input and output are
invertbile.  Note that the documentation for these fields never mentioned
strptime or strftime, but says the are long intergers requiring long
integer printf conversions.

* Fix TIMET_TIME, TIMET_TIME_MS documentation.

These have been converted to 64 bit values to prepare for 2038.

* update style files for 64bit TIMET_TIME, TIMET_TIME_MS.

6 years agoQt5127 (#489)
tsteven4 [Sun, 2 Feb 2020 19:08:40 +0000 (12:08 -0700)]
Qt5127 (#489)

* update to Qt 5.12.7

switch to online Qt installer.
Note the latest Qt online installer, 3.2.1, can crash on macos.
https://bugreports.qt.io/projects/QTIFW/issues/QTIFW-1592
For this reason we use the previous installer on macos.

* add missing online install script.

* update more travis install scripts.

* also switch Qt 5.9 builds to 5.9.9.

make install target optional in install-qt-online.

* fix linux install scripts, enable Qt archive

* add new installer dependencies.

* fix travis linux install scripts some more.

6 years agoFix memory leak in lowranceusr version 4 writer. (#487)
tsteven4 [Fri, 31 Jan 2020 17:56:02 +0000 (10:56 -0700)]
Fix memory leak in lowranceusr version 4 writer. (#487)

* fix memory leak in lowranceusr version 4 writer.

memory was still reachable, due to global pointer it wasn't lost.

* fix include.

6 years agoconvert xcsv format to sub-class of Format. (#481)
tsteven4 [Thu, 30 Jan 2020 18:06:25 +0000 (11:06 -0700)]
convert xcsv format to sub-class of Format.  (#481)

* convert xcsv format to sub-class of Format.

* move XcsvStyle functions inside class.

* Unnest XcsvStyle.

* remove redundant qualifiers.

6 years agoclang-tidy modernize-use-auto, part 2, but (#485)
tsteven4 [Thu, 30 Jan 2020 17:30:37 +0000 (10:30 -0700)]
clang-tidy modernize-use-auto, part 2, but (#485)

* clang-tidy modernize-use-auto, part 2, but

only on:
Message: use auto when initializing with a cast to avoid duplicating the type name

not on:
Message: use auto when initializing with new to avoid duplicating the type name
Message: use auto when initializing with a template cast to avoid duplicating the

Before running clang-tidy gbfile.h was changed to replace the macro definition of
gbfopen_le, gbfgetuint32, gbfgetuint16, gbfputuint16, gbfputuin32 with inline
function definitions.  Without this change the application of modernize-use-auto
made it difficult to recognize the type of the result. Note this change has merit
of it's own,
see https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-macros

This was run with clang-tidy from llvm version 8.  It generate serveral
compilation errors that will be fixed by hand in the next commit.

* fix errors introduced by clang-tidy modernize-use-auto.

These errors are of the form:
error: variable 'myvar' declared with deduced type 'auto *' cannot appear in its own initializer
They arose from patterns like:
mytype* myvar = (mytype*) xcalloc(1, sizeof(*myvar));
which clang-tidy changed to
auto* myvar = (mytype*) xcalloc(1, sizeof(*myvar));

These were edited by hand to the form
auto* myvar = (mytype*) xcalloc(1, sizeof(mytype));

At the same time, the order of the parameters in calls to
xcalloc was corrected.

6 years agoclang-tidy modernize-use-auto, but (#483)
tsteven4 [Wed, 29 Jan 2020 15:32:32 +0000 (08:32 -0700)]
clang-tidy modernize-use-auto, but (#483)

only on:
Message: use auto when initializing with new to avoid duplicating the type name

not on:
Message: use auto when initializing with a cast to avoid duplicating the type name
Message: use auto when initializing with a template cast to avoid duplicating the

The later two left me wondering what type I had, while it is obvious with the first
one.  Some of this is due to our macro defines for gbffetuint*, gbfputuint*.

This required a edit of the fixes file produced by clang-tidy:
export PAT='with a template' A=3 B=3
vim -Nes "+g/${PAT}/.-${B},.+${A}d" '+w !tee' '+q!' ct8fixes.yaml > tmp1.yaml
export PAT='with a cast' A=2 B=3
vim -Nes "+g/${PAT}/.-${B},.+${A}d" '+w !tee' '+q!' tmp1.yaml > myfixes.yaml
rm ct8fixes.yaml
rm tmp1.yaml

6 years agoeliminate const_cast from lowranceusr. (#480)
tsteven4 [Tue, 28 Jan 2020 16:42:05 +0000 (09:42 -0700)]
eliminate const_cast from lowranceusr. (#480)

6 years agorework gathering of serialization information. (#479)
tsteven4 [Tue, 28 Jan 2020 02:08:51 +0000 (19:08 -0700)]
rework gathering of serialization information. (#479)

The existing method broke encapsulation to generate the combined
list of regular and style based formats.  It required access to
xcsv_vecs, which is only present in LegacyFormats.  Until recently
it also required access to xcsv_file.

The existing method also leaked memory, although the use case was
such that the program always exited shortly thereafter.

All these issues are resolved during unification by gathering all the
necessary information and passing that on to serialization.  This
information is gathered from different places for regular and style
based formats.

6 years agoImprove xcsv modularization, fix some xcsv end cases. (#476)
tsteven4 [Mon, 27 Jan 2020 22:00:17 +0000 (15:00 -0700)]
Improve xcsv modularization, fix some xcsv end cases.  (#476)

* Improve xcsv modularization, fix some xcsv end cases.

Add a test for various textual outputs from main.  Some of these are
for the user, and some of these are primarly for passing information
to the doc or the GUI.  While the reference files will have to change
anytime we add/delete a filter or format, or anytime a filter or format
has an arugment change, this test prevents bugs from unintentionally
changing the information passed to the GUI.  As the GUI has no automated
test those types of bugs are difficult to find.

Enhance csv test to cover more end cases with the xcsv format. Historically
these cases have involved a series of xcsv format operations.  These operations
may be using internal style files or passed style files.  These operations may
or may not involve postional arugments on the command line.  Some of these end
cases represented bugs previous to this PR, e.g. a series of input operations
where a xcsv format using an internal style is followed by an xcsv format using
a passsed style file.

Refactor XcsvFile, splitting sytle information into XcsvStyle.  This allows
xcsv_file to be private.  A XcsvStyle object is returned to Vecs by
xcsv_read_internalstyle that can Vecs can parse to build vectors containing
the real formats and the style based formats.  This also eliminates bugs as
we build a new XcsvFile object every time we parse an external or internal
style file so we don't have any accidental dependiencies on previous operations.

Some other xcsv bugs are fixed:
  DATUM was always ignored in a style file.
  #474 xcsv style derived formats may have wrong GUI and/or CLI capability.
    Behavoir now matches the document, which is likely not to be what some of
    the style file authors intended!  E.g. should gpsdrivetrack really be
    working with waypoints as they do after this PR and as is documented,
    or was the accidental operation with tracks desired?

Use gpsbabel::textstream in xcsv.

Stay tuned for xcsv to become a real Format as opposed to a LegacyFormat.

* try to get serialization test to work across OSs.

* disable serialization test under valgrind ...

and disable usage test on all platforms.

we have known leaks in Vecs::sort_and_unify.
usage test fails on windows under appveyor, the sed line doesn't
seem to work.

* ok, twos tests have the executable name embedded.

* Limit # of waypoints holux writer tries to write

so the writer doesn't write passed the end of the write buffer.

* eliminate unnecessary const_cast.

6 years agoConvert mynav to Format sub-class (#472)
Ralf Horstmann [Mon, 27 Jan 2020 21:24:04 +0000 (22:24 +0100)]
Convert mynav to Format sub-class (#472)

* Convert mynav to Format sub-class

While there, switch to gpsbabel::File, QTextStream, and introduce
enum for line type.

* Switch mynav to TextStream

* Include cleanup in mynav

* Correct includes, add link to spec for mynav format

6 years agoDelete unused cet bits. (#469)
tsteven4 [Mon, 27 Jan 2020 21:09:13 +0000 (14:09 -0700)]
Delete unused cet bits. (#469)

Try to consistently use Latin1 for garmin format.

6 years agomodify format access to waypts via global list. (#478)
tsteven4 [Mon, 27 Jan 2020 19:22:23 +0000 (12:22 -0700)]
modify format access to waypts via global list. (#478)

As a rule writers should not modify waypoints on the global list.
One way this can happen is if the writer uses the global waypoint
list, global_waypoint_list.  Via the list pointers to non-const
Waypoints can be accessed.  The three writers that use the
global_waypoint_list all did not modify any waypoints, but it was not obvious.
This PR makes it obvious by getting const Waypoint pointers from the list.
This required some const correctness corrections in these writers.

As a rule readers should not modify waypoints they didn't add to the
global list.
One way this can happen is if the reader uses the global waypoint list.
One reader was inapproprieately modifying waypoints on the global list.
While this is OK for waypoints it added, it is not OK for any waypoints
that were added by other readers.  This PR fixes a bug where the
netsumbler reader, intending to modify waypoints it added to the list,
actually modified all waypoints on the list.

6 years agorefactor height filter to appease cppcheck & MSVC (#473)
tsteven4 [Sun, 26 Jan 2020 15:26:58 +0000 (08:26 -0700)]
refactor height filter to appease cppcheck & MSVC (#473)

* refactor heightgrid to appease cppcheck.

With newer versions (somwhere after 1.82) of cppcheck analyzing
height.cc took an excessive amount of time.
By making these variables private static class members instead of
member function static variables we avoid the cppcheck issues.

* tweak height to work around MSVC 2017 error.

and hopefully MSVC 2015 error as well.

* don't include cstdint within class definition.

It can lead to compile failures.  This was done in heightgrid.h,
but the include guards in cstdint hid the error.

6 years agofix some xcsv bugs. (#477)
tsteven4 [Sun, 26 Jan 2020 15:04:36 +0000 (08:04 -0700)]
fix some xcsv bugs. (#477)

These led to non-sensical motoactv files in test-all.  These
non-sensical files lead to the discovery of a holux write passed
end of buffer bug.

1. fea062ee7 writtime expects a strftime format specification.
When writing XT_TIMET_TIME_MS with writtime the strpftime format
specification ("%s") that was previously used was replaced by a printf
format specification ("%ld").  Thus the twelve hour clock followed by
a 'd' character was printed instead of the number of seconds since the Epoch.

2. 172073cdb When intending to print the field encloser the record
delimiter printed instead.

6 years agoCheckpoint yahoo work. This gets messy because xml_format really wants C pointers...
Robert Lipe [Sun, 26 Jan 2020 10:42:29 +0000 (04:42 -0600)]
Checkpoint yahoo work. This gets messy because xml_format really wants C pointers to member functions so we'll probably have to shim in an instance and a fake 'this'.

6 years agogpsbabel::textstream now accepts open mode flags (#475)
tsteven4 [Sat, 25 Jan 2020 16:34:59 +0000 (09:34 -0700)]
gpsbabel::textstream now accepts open mode flags (#475)

Previously only an open mode flag was accepted, now a combination
of flags will be accepted.

6 years agoupdate codacy coverage tool. (#471)
tsteven4 [Wed, 22 Jan 2020 01:24:11 +0000 (18:24 -0700)]
update codacy coverage tool. (#471)

6 years agotry to get codacy cppcheck running without height.cc (#470)
tsteven4 [Wed, 22 Jan 2020 00:11:34 +0000 (17:11 -0700)]
try to get codacy cppcheck running without height.cc (#470)

6 years agoConvert ggv_bin format to sub-class of Format (#462)
Ralf Horstmann [Tue, 21 Jan 2020 22:10:34 +0000 (23:10 +0100)]
Convert ggv_bin format to sub-class of Format (#462)

* Convert ggv_bin format to sub-class of Format

* Add ggv_bin helpers as class member functions

* Style improvements in ggv_bin

6 years agoDon't lie to mkshort about utf8. (#468)
tsteven4 [Tue, 21 Jan 2020 15:32:09 +0000 (08:32 -0700)]
Don't lie to mkshort about utf8. (#468)

Pass a flag indicating utf8 on every call to mkshort, instead of
setting it up in the handle.  This is much more likely to be correct
as the string and the flag are passed together.  The old method was
often incorrect as it was based on global_opts.charset, which was
often unrelated to the string that was passed to mkshort.

This also resolved an apparent bug in psitrex.  It was thought
that passing a nullptr to mkshort was a bug, but this results in
the result being generated from the default name.  It is assumed
that this is what was originally intended, and this was never a bug.

6 years agoDrop backup/restore of wpts, rtes, trks in main. (#467)
tsteven4 [Tue, 21 Jan 2020 01:25:22 +0000 (18:25 -0700)]
Drop backup/restore of  wpts, rtes, trks in main. (#467)

PR #459, df03a17, eliminated cet_covert_strings from main.cc.

Thus there is no need to backup and restore waypoints, routes,
and tracks when running a format writer.

For the same reason we no longer need to push and pop verbose
status when running a format writer or display the waypoints in the
case that no format writer was used.

6 years agofix RouteList::copy() (#466)
tsteven4 [Tue, 21 Jan 2020 00:10:30 +0000 (17:10 -0700)]
fix RouteList::copy() (#466)

which failed to copy some members of each route, specifically
line_color, line_width, session.

6 years agoremove HAVE_LINUX_HID support from builds. (#465)
tsteven4 [Mon, 20 Jan 2020 18:01:12 +0000 (11:01 -0700)]
remove HAVE_LINUX_HID support from builds. (#465)

We haven't used this for some time.

6 years agoDatetime optimization (#439)
tsteven4 [Mon, 20 Jan 2020 17:09:52 +0000 (10:09 -0700)]
Datetime optimization (#439)

* Optimize performance of DateTime.

Prefer Qt::UTC TimeSpec for storing creation_time.
This avoids very significant performance hits from converting
to/from Qt::LocalTime, which involve DST calculations as well
as the usual offsets.
Test suite with this commit runs at 63% of wall-clock time of the
baseline (time ./testo)!

* remove obsolete fromTime_t and use Qt::UTC.

* Delete obsolete operators and methods of DateTime.

* document motivation for Qt::UTC as default timespec.

Modify Waypoint::SetCreationTime so it can be used with seconds, milliseconds,
or both operands.  This method is implemented without resetting the
Qt::TimeSpec.  It will be efficient if the existing TimeSpec is
Qt::UTC as set up by gpsbabel::DateTime default constructor.

6 years agoAdd OpenBSD support to qmake project (#464)
Ralf Horstmann [Sun, 19 Jan 2020 22:28:12 +0000 (23:28 +0100)]
Add OpenBSD support to qmake project (#464)

* Add OpenBSD support to qmake project

* Set HAVE_LINUX_HID only on Linux in CMakeLists.txt

6 years agoeliminate cet usage in destinator, igo8, mmo. (#463)
tsteven4 [Sat, 18 Jan 2020 21:46:24 +0000 (14:46 -0700)]
eliminate cet usage in destinator, igo8, mmo. (#463)

* eliminate cet usage in igo8 format.

added test to verify written header.
This test requires spaces to be embedded within option strings.
testo had to be modififed to preserve these embedded spaces.

* eliminate cet usage in destinator.

* eliminate cet usage in mmo.

This also fixes some apparent encoding/decoding bugs, although
our understanding of this binary format is likely incomplete.

* use smart pointer with encoders/decoders.

* fix bad resolution of merge conflict.

6 years agoMerge pull request #453 from ra1fh/ggv-bin-int-overflow
GPSBabel [Sat, 18 Jan 2020 17:15:04 +0000 (11:15 -0600)]
Merge pull request #453 from ra1fh/ggv-bin-int-overflow

Prevent negative len in ggv_bin_read_bytes.

6 years agoretire cet_convert_strings (#459)
tsteven4 [Sat, 18 Jan 2020 16:04:07 +0000 (09:04 -0700)]
retire cet_convert_strings (#459)

* prepare to eliminate char strings from garmin_fs_t.

* retire cet_covnert_strings

The only use was for garmin specific data(gmsd).
gmsd is migrated from char strings to QStrings,
and any necessary conversions are handled within the formats using
gmsd.
This takes main out of the string conversion business.

* fix gmsd related memory leaks.

and eliminate a little back and forth between
char strings and QStrings.

csv_stringtrim has 3 signatures:
1. char*,char*,int returning char* that must be free'd.
2. QString,QString returning QString
3. QString,QString,int returing QString

We may want to consider replacing 2. with 3. and a default for
the 3rd argument.

6 years agoclean up make icon doc. (#460)
tsteven4 [Fri, 17 Jan 2020 23:49:38 +0000 (16:49 -0700)]
clean up make icon doc. (#460)

and fix an old capitalization error in the document.

6 years agouse QTextStream for garmin_txt format. (#458)
tsteven4 [Thu, 16 Jan 2020 02:25:00 +0000 (19:25 -0700)]
use QTextStream for garmin_txt format. (#458)

6 years agoeliminate usage of obsolete QString::sprintf(). (#457)
tsteven4 [Sun, 12 Jan 2020 14:08:57 +0000 (07:08 -0700)]
eliminate usage of obsolete QString::sprintf(). (#457)

in favor of the merely not recommended QString::asprintf().

6 years agofix potential memory leaks in ggv_ovl. (#456)
tsteven4 [Sat, 11 Jan 2020 20:04:49 +0000 (13:04 -0700)]
fix potential memory leaks in ggv_ovl. (#456)

* fix potential memory leaks in ggv_ovl.

* ggv_ovl control flow and string processing tweaks.

6 years agoPrevent negative len in ggv_bin_read_bytes.
Ralf Horstmann [Mon, 6 Jan 2020 20:55:10 +0000 (21:55 +0100)]
Prevent negative len in ggv_bin_read_bytes.

Both QByteArray::resize and QIODevice::read handle negative
len values gracefully, but there is no error status returned and
parsing fails later at and unrelated location. So better fail
early instead.

6 years agoIntroduce Format class (#449)
tsteven4 [Sat, 11 Jan 2020 15:53:05 +0000 (08:53 -0700)]
Introduce Format class (#449)

Also, introduce Vecs and FilterVecs classes. These are implemented as Meyers singeltons. This avoids some issues with initialization order.

All formats except gpx are used as LegacyFormats, which is deprecated. The gpx format has been converted to demonstrate the preferred usage.

6 years agoUse https for www.gpsbabel.org (#450)
Chris Mayo [Sat, 11 Jan 2020 00:01:41 +0000 (00:01 +0000)]
Use https for www.gpsbabel.org (#450)

6 years agoCetcleanup (#454)
tsteven4 [Fri, 10 Jan 2020 20:47:24 +0000 (13:47 -0700)]
Cetcleanup (#454)

* remove some obsolete cet code.

* chip away at cet a bit more.

* repair GDB_DEBUG, eliminating cet usage.

6 years agofix char string corruption with xcsv. (#455)
tsteven4 [Fri, 10 Jan 2020 20:12:11 +0000 (13:12 -0700)]
fix char string corruption with xcsv. (#455)

Any gmsd char string data handled by the xcsv format could be
corrupted when main ran cet_convert_strings.  The xml format
reader/writer use a QTextCodec to handle all char string conversion,
but the data was converted again by cet_convert_strings ... garmin_fs_convert
to/from ASCII, resulting in corruption.

Add a test case for the above.

Add xcsv format support for gmsd email field.

6 years agocorrect url for filter documentation. (#452)
tsteven4 [Mon, 6 Jan 2020 16:04:32 +0000 (09:04 -0700)]
correct url for filter documentation. (#452)

6 years agoMerge pull request #451 from tsteven4/translations
tsteven4 [Wed, 1 Jan 2020 22:46:09 +0000 (15:46 -0700)]
Merge pull request #451 from tsteven4/translations

update translations

6 years agoupdate all the translation files.
tsteven4 [Wed, 1 Jan 2020 22:09:15 +0000 (15:09 -0700)]
update all the translation files.

6 years agocatch de translation up with old change.
tsteven4 [Wed, 1 Jan 2020 21:59:38 +0000 (14:59 -0700)]
catch de translation up with old change.

Change was 55508d19b2, Sep 12 2015.

6 years agostore QXmlStreamAttributes in xml_tag. (#441)
tsteven4 [Sat, 28 Dec 2019 19:01:03 +0000 (12:01 -0700)]
store QXmlStreamAttributes in xml_tag. (#441)

* store QXmlStreamAttributes in xml_tag.

instead of arrays of char strings.  This simplified xml_tag
handling.

Correct encoding issues with text and html formats.

Enhance test coverage of text and html formats.

* clean up xml attributes handling.

6 years agoUpdate igc.cc with new Header type S (#446)
rolfoz [Mon, 23 Dec 2019 14:38:22 +0000 (22:38 +0800)]
Update igc.cc with new Header type S (#446)

Add the new Header type S to allowed values on line 308

6 years agohide magic time value from test mode decisions. (#443)
tsteven4 [Thu, 19 Dec 2019 16:44:18 +0000 (09:44 -0700)]
hide magic time value from test mode decisions. (#443)

6 years agoFix test generating gpx schema violations. (#444)
tsteven4 [Thu, 19 Dec 2019 15:37:42 +0000 (08:37 -0700)]
Fix test generating gpx schema violations. (#444)

TODO: Detect bad input coordinates.

6 years agouse QDebug in logging. (#438)
tsteven4 [Tue, 17 Dec 2019 21:39:48 +0000 (14:39 -0700)]
use QDebug in logging. (#438)

* use QDebug in logging.

This gives us full access to all the methods, stream operators and
manipulators that QDebug has access to.

* silence warning on unhandled fix values in nmea.

6 years agoFix potential slicing with Filter class. (#440)
tsteven4 [Tue, 17 Dec 2019 14:23:05 +0000 (07:23 -0700)]
Fix potential slicing with Filter class. (#440)

detected by clazy as:
warning: Polymorphic class Filter is copyable. Potential slicing. [-Wclazy-copyable-polymorphic]

6 years agofix NMEA date fiddling. (#437)
tsteven4 [Fri, 13 Dec 2019 21:48:18 +0000 (14:48 -0700)]
fix NMEA date fiddling. (#437)

Three errors were corrected:
1) SECONDS_PER_DAY is assumed to be an integer type.  It was recently
errorously changed to to double.
2) when backfilling dates we need to subtract a day at rolloever,
not addit.
3) If we have a date, then it came with a time.  Don't set the backfill
time to 23:59:59.

Add test coverage for the above.

6 years agoDelete file erroneously added in #409. (#435)
tsteven4 [Wed, 11 Dec 2019 14:47:35 +0000 (07:47 -0700)]
Delete file erroneously added in #409. (#435)

6 years agoMerge pull request #409 from gpsbabel/no_new_string
Robert Lipe [Wed, 11 Dec 2019 07:11:04 +0000 (01:11 -0600)]
Merge pull request #409 from gpsbabel/no_new_string

Remove remnants of NEW_STRINGS

6 years agoMerge pull request #433 from gpsbabel/cleanups_201912
Robert Lipe [Wed, 11 Dec 2019 03:03:58 +0000 (21:03 -0600)]
Merge pull request #433 from gpsbabel/cleanups_201912

Cleanups: make a gbfreadbuf, move units from defs and into dedicated file, reduce xstrdup,xmalloc use, reduce CString/QString roundtrips, more.

6 years agotweaks for format vectors. (#434)
tsteven4 [Mon, 9 Dec 2019 18:39:58 +0000 (11:39 -0700)]
tweaks for format vectors. (#434)

flush out hiketech capability array.

use copy constructor of ff_vecs_t when creating unified vector list.

6 years agoCleanup train keeps rollin' along
Robert Lipe [Mon, 9 Dec 2019 17:30:31 +0000 (11:30 -0600)]
Cleanup train keeps rollin' along
defs.h: use c++ true and false. Replace macros with constexprs.
gbser_win.cc don't use Windows style TRUE/FALSE.
kml.cc: integration suggestions.
msvc build: use units.h

6 years agoAdd util.h to various build files.
Robert Lipe [Mon, 9 Dec 2019 15:55:43 +0000 (09:55 -0600)]
Add util.h to various build files.

6 years agoMechanically move protos and structs for units.cc from defs.h to units.h
Robert Lipe [Mon, 9 Dec 2019 15:41:57 +0000 (09:41 -0600)]
Mechanically move protos and structs for units.cc from defs.h to units.h

6 years agoA bunch of busy-work in coce that approximarly never is actually run but solely for...
Robert Lipe [Mon, 9 Dec 2019 08:26:50 +0000 (02:26 -0600)]
A bunch of busy-work in coce that approximarly never is actually run but solely for the hope of hushing clang, clion, and codacy.

6 years agoFix ordering in optional altitude test in KML reader
Robert Lipe [Mon, 9 Dec 2019 06:55:31 +0000 (00:55 -0600)]
Fix ordering in optional altitude test in KML reader

6 years agoWarning tweaks in defs for safety in macro expansion.
Robert Lipe [Mon, 9 Dec 2019 05:56:50 +0000 (23:56 -0600)]
Warning tweaks in defs for safety in macro expansion.

6 years agoLargely automated cleanups in NMEA.
Robert Lipe [Mon, 9 Dec 2019 05:55:59 +0000 (23:55 -0600)]
Largely automated cleanups in NMEA.

6 years agoRework KML linestring coordinate reader. About a 21x speedup on a file
Robert Lipe [Mon, 9 Dec 2019 05:49:32 +0000 (23:49 -0600)]
Rework KML linestring coordinate reader. About a 21x speedup on a file
with 38,000 coordinates tuples.

6 years agoMake WAYPT_SET act more like a function after macro expansion.
Robert Lipe [Mon, 9 Dec 2019 01:37:32 +0000 (19:37 -0600)]
Make WAYPT_SET act more like a function after macro expansion.

6 years agoLowranceusr: internal tightening of types, better scope management.
Robert Lipe [Mon, 9 Dec 2019 01:14:09 +0000 (19:14 -0600)]
Lowranceusr: internal tightening of types, better scope management.

6 years agoMake GPX internal promotions/reductions more specific.
Robert Lipe [Mon, 9 Dec 2019 01:11:48 +0000 (19:11 -0600)]
Make GPX internal promotions/reductions more specific.
Automated cleanups courtesy Clion.

6 years agoAdd gbfreadbuf to simplify object storage.
Robert Lipe [Mon, 9 Dec 2019 01:10:19 +0000 (19:10 -0600)]
Add gbfreadbuf to simplify object storage.

6 years agoMake tpo less weird. Rely on xmalloc/xfree way less. Reduce internal copies.
Robert Lipe [Mon, 9 Dec 2019 01:07:30 +0000 (19:07 -0600)]
Make tpo less weird. Rely on xmalloc/xfree way less. Reduce internal copies.